#pragma once

#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string>

class InetAddr
{
private:
    void GetAddress()
    {
        _ip = inet_ntoa(_addr.sin_addr);
        _port = ntohs(_addr.sin_port);
    }

public:
    InetAddr(struct sockaddr_in &addr) : _addr(addr)
    {
        GetAddress();
    }
    std::string Ip()
    {
        return _ip;
    }
    uint16_t Port()
    {
        return _port;
    }

    bool operator==(const InetAddr &Addr)
    {
        return (_ip == Addr._ip && _port == Addr._port);
    }

    struct sockaddr_in Addr()
    {
        return _addr;
    }

private:
    struct sockaddr_in _addr;
    std::string _ip;
    uint16_t _port;
};